{include file="index/header" /}
<div class="layui-row layui-col-space10">
    <div class="layui-col-md6">
        <div class="layui-card">
            <div class="layui-card-header">基本信息配置</div>
            <div class="layui-card-body">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">网站地址：</label>
                        <div class="layui-input-block">
                            <input type="text" name="url" lay-verify="required" placeholder="请输入网站地址"
                                   autocomplete="off" class="layui-input" value="{$sys.url|default='http://localhost'}">
                            <div class="layui-word-aux">需要填写http(s)://。{:checkHost()}</div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">网站标题：</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" lay-verify="required" placeholder="请输入网站标题"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.title|default='WXSSK-Tools 程序员工具箱'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">网站关键词：</label>
                        <div class="layui-input-block">
                            <input type="text" name="keyword" placeholder="请输入网站关键词，用英文,隔开"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.keyword|default='WXSSK,Tools,程序员工具箱'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">网站描述：</label>
                        <div class="layui-input-block">
                            <input type="text" name="description" placeholder="请输入网站描述"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.description|default='WXSSK,Tools,程序员工具箱'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备案号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="icp" placeholder="请输入备案号"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.icp|default='WXSSK,Tools,程序员工具箱'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">自定义CSS：</label>
                        <div class="layui-input-block">
                            <textarea name="custom_css" class="layui-textarea">{$sys.custom_css}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">自定义JS：</label>
                        <div class="layui-input-block">
                            <textarea name="custom_js" class="layui-textarea">{$sys.custom_js}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">系统公告(支持html)：</label>
                        <div class="layui-input-block">
                            <textarea name="notice" placeholder="系统公告(支持html)"
                                      class="layui-textarea">{$sys.notice}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item text-center">
                        <button type="button" lay-submit lay-filter="save"
                                class="layui-btn layui-btn-normal layui-btn-sm">&nbsp;&nbsp;保&nbsp;存&nbsp;&nbsp;
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="layui-col-md6">
        <div class="layui-card">
            <div class="layui-card-header">logo设定</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <label class="layui-form-label">logo预览：</label>
                    <div class="layui-input-block layui-bg-black">
                        <img id="preview_logo" src="__IMG__/{$sys.logo}" style="max-height: 50px"/>
                    </div>
                </div>
                <div class="layui-form-item text-center">
                    <button type="button" id="upload_logo" class="layui-btn layui-btn-normal layui-btn-sm">&nbsp;&nbsp;上传logo&nbsp;&nbsp;</button>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md6">
        <div class="layui-card">
            <div class="layui-card-header">邮箱信息(SMTP)设定 [<span class="font-red">默认ssl安全方式</span>]</div>
            <div class="layui-card-body">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">发件人名称：</label>
                        <div class="layui-input-block">
                            <input type="text" name="mailer" lay-verify="required" placeholder="请输入发件人名称"
                                   autocomplete="off" class="layui-input" value="{$sys.mailer|default='WJSSK'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">发件邮箱地址：</label>
                        <div class="layui-input-block">
                            <input type="text" name="send_mail" lay-verify="required" placeholder="请输入发件邮箱地址"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.send_mail|default='123456789@qq.com'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮件回复地址：</label>
                        <div class="layui-input-block">
                            <input type="text" name="request_mail" placeholder="请输入邮件回复地址"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.request_mail|default='123456789@qq.com'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SMTP地址：</label>
                        <div class="layui-input-block">
                            <input type="text" name="smtp_addr" placeholder="请输入SMTP地址"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.smtp_addr|default='smtp.qq.com'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SMTP端口：</label>
                        <div class="layui-input-block">
                            <input type="text" name="smtp_port" placeholder="请输入SMTP端口(465/587)"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.smtp_port|default='465'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SMTP登录用户：</label>
                        <div class="layui-input-block">
                            <input type="text" name="smtp_login" placeholder="请输入SMTP地址"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.smtp_login|default='123456789@qq.com'}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SMTP登录密码：</label>
                        <div class="layui-input-block">
                            <input type="text" name="smtp_pass" placeholder="请输入SMTP地址"
                                   autocomplete="off" class="layui-input"
                                   value="{$sys.smtp_pass|default='12345678'}">
                        </div>
                    </div>
                    <div class="layui-form-item text-center">
                        <button type="button" lay-submit lay-filter="save"
                                class="layui-btn layui-btn-normal layui-btn-sm">&nbsp;&nbsp;保&nbsp;存&nbsp;&nbsp;
                        </button>
                        <button type="button" id="test_send" class="layui-btn layui-btn-warm layui-btn-sm">&nbsp;&nbsp;测试邮箱&nbsp;&nbsp;</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery', 'form', 'upload'], function () {
        var $ = jq = layui.jquery,
            form = layui.form,
            upload = layui.upload;

        form.on("submit(save)", function (obj) {
            $.post("{:url('save')}", obj.field, function (info) {
                if (info.code) {
                    layer.msg(info.msg);
                } else {
                    layer.alert(info.msg);
                }
            }, 'json')
            return false;
        });
        var uploadInst = upload.render({
            elem: '#upload_logo' //绑定元素
            , url: '/admin/upload/logo' //上传接口
            , done: function (res) {
                if (res.code) {
                    layer.msg('上传[logo]成功！');
                    $('#preview_logo').attr('src', res.data.src);
                }
            }
            , error: function () {
                //请求异常回调
            }
        });
        $('#test_send').on('click', function () {
            layer.prompt({title: '请输入接受邮箱'}, function (value, index, elem) {
                layer.close(index);
                var load = layer.load(2);
                $.get("{:url('sendMail')}", {receive_mail: value}, function (info) {
                    layer.close(load);
                    layer.msg(info.msg);
                }, 'json');
            });
        });
    });
</script>
{include file="index/footer" /}